package com.leju.common.dao.base;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {
	DBHelper mdHelper = null;

	public static OnDbUpgradeListener onDbUpgradeListener = null;


	public DBHelper(Context context,int version) {

		super(context, "leju.db", null, version);

	}
	public DBHelper(Context context, String dbname, int version) {

		super(context, dbname, null, version);

	}



	@Override
	public void onCreate(SQLiteDatabase db) {

		
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		if (onDbUpgradeListener != null) {
			onDbUpgradeListener.onUpgrade(db, oldVersion, newVersion);
		}

		/*
		 * db.execSQL("DROP TABLE IF EXISTS " + "special");
		 * db.execSQL("DROP TABLE IF EXISTS " + "city");
		 */
	}
    /**
     * 在程序入口处设置，在实例化DBHelper之前调用
     * @param listener
     */
	public static void setOnDbUpgradeListener(OnDbUpgradeListener listener) {
		onDbUpgradeListener = listener;
	}

	public interface OnDbUpgradeListener {
		public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion);
	}
}
